﻿package com._public._utils._mailer
{
	/**
	 * 126邮箱
	 * 
	 * @author laan
	 * @createTime 200908
	 * 
	 */	
	public class Mailer126 extends Mailer
	{
		public function Mailer126()
		{
			super();
		}
		
		/**
		 * 创建邮件发送步骤数据
		 * 
		 * @return 	Array
		 * 
		 */		
		override protected function createSendMailSteps(mail:Mail):Array {
			var steps:Array = [];
			
			steps.push("HELO laan");
			steps.push("AUTH login");
			
			steps.push(Base64.encode(userName));
			
			steps.push(Base64.encode(password));
			
  			steps.push("MAIL FROM:<" + mail.from + ">");
  			steps.push("RCPT TO:<" + mail.tu + ">");
  			
  			if (mail.cc) {
  				var cc:Array = mail.cc.split(",");
  				
  				for(var i:uint = 0; i < cc.length; i++) {
		  			steps.push("RCPT TO:<" + cc[i] + ">");
  				}
  			}
  			
  			steps.push("DATA");
  			
  			
			var mailData:Array = [];
			if (!mail.fromName) {
	  			mailData.push("From:" + mail.from);
			} else {
	  			mailData.push("From:" + mail.fromName);
			}
			
			if (!mail.toName) {
	  			mailData.push("To:" + mail.tu);
			} else {
	  			mailData.push("To:" + mail.toName);
			}
			
  			if (mail.subject) {
  				mailData.push("Subject:" + mail.subject);
  			}
  			
  			if (mail.cc) {
  				mailData.push("CC:" + mail.cc);
  			}
  			
  			if (mail.sender) {
  				mailData.push("Sender:" + mail.sender);
  			}
  			
  			//trace(mail.date);
  			//mailData.push("Date:" + mail.date);
  			
  			mailData.push("");
  			mailData.push(mail.body);
  			mailData.push(".");
  			
  			
  			steps.push(mailData);
  			steps.push("QUIT");
  			
  			return steps;
		}
	}
}